#include <iostream>
using namespace std;

struct Node
{
    int val;
    Node* next;

    Node(int _val) : val(_val), next(NULL) {}
};

int main()
{
    //定义链表
    Node* p = new Node(1);
    Node* q = new Node(2);
    Node* o = new Node(3);

    p->next = q;
    q->next = o;

    Node* head = p;

    //添加节点
    Node* u = new Node(4);
    u->next = head;
    head = u;

    //删除节点
    head->next = head->next->next;

    //遍历链表
    for (Node* i = head; i; i = i->next)//当i为0时停止
        cout << i->val << endl;

    return 0;
}